package com.design.pattern.principle;

public class SingleResponsibiltty2 {
    public static void main(String[] args) {
        //方案二遵守了单一职责原则
        new RoadVehicle().run("摩托车");
        new RoadVehicle().run("汽车");
        new AirVehicle().run("飞机");
        new WaterVehicle().run("轮船");
    }
}

/**
 * 1. 方案二遵守了单一职责原则
 * 2. 但是这样做它的花销/改动 很大，即将类分别，同时也要修改客户端
 * 3. 可以在基础上再次进行改进，直接修改原先的类，改动的代码会比较少
 */
class RoadVehicle {
    public void run(String vehicle) {
        System.out.println(vehicle + "公路运行");
    }
}

class AirVehicle {
    public void run(String vehicle) {
        System.out.println(vehicle + "空中运行");
    }
}

class WaterVehicle {
    public void run(String vehicle) {
        System.out.println(vehicle + "水中运行");
    }
}